package com.cug.campus_sh_market_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cug.campus_sh_market_server.entity.param.college.CollegeAddParam;
import com.cug.campus_sh_market_server.entity.param.goodstype.GoodsTypeAddParam;
import com.cug.campus_sh_market_server.entity.param.goodstype.GoodsTypeQueryParam;
import com.cug.campus_sh_market_server.entity.param.goodstype.GoodsTypeUpdateParam;
import com.cug.campus_sh_market_server.entity.po.College;
import com.cug.campus_sh_market_server.entity.po.GoodsType;
import com.cug.campus_sh_market_server.entity.vo.college.CollegeVO;
import com.cug.campus_sh_market_server.entity.vo.goodstype.GoodsTypeVO;
import com.cug.campus_sh_market_server.mapper.GoodsTypeMapper;
import com.cug.campus_sh_market_server.service.GoodsTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商品类型 服务实现类
 * </p>
 *
 * @author sxt
 * @since 2022-03-22
 */
@Service
public class GoodsTypeServiceImpl
        extends CustomRestfullServiceImpl
        <GoodsType, GoodsTypeQueryParam, GoodsTypeAddParam, GoodsTypeUpdateParam, GoodsTypeVO>
        implements GoodsTypeService {

    @Override
    public GoodsTypeVO saveWithBackData(GoodsTypeAddParam goodsTypeAddParam) {
        int count = this.count(new QueryWrapper<GoodsType>().lambda().eq(GoodsType::getType, goodsTypeAddParam.getType()));
        if (count > 0) {
            return null;
        }
        return super.saveWithBackData(goodsTypeAddParam);
    }
}
